﻿namespace Chain.BLL
{
    using Chain.DAL;
    using Chain.Model;
    using System;
    using System.Collections.Generic;
    using System.Data;

    public class WeiXinRule
    {
        private readonly Chain.DAL.WeiXinRule dal = new Chain.DAL.WeiXinRule();

        public int Add(Chain.Model.WeiXinRule model)
        {
            return this.dal.Add(model);
        }

        public DataTable Attention()
        {
            return this.dal.Attention();
        }

        public string AttentionStr()
        {
            return this.dal.AttentionStr();
        }

        public List<Chain.Model.WeiXinRule> DataTableToList(DataTable dt)
        {
            List<Chain.Model.WeiXinRule> list = new List<Chain.Model.WeiXinRule>();
            int count = dt.Rows.Count;
            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    Chain.Model.WeiXinRule item = new Chain.Model.WeiXinRule();
                    if ((dt.Rows[i]["RuleID"] != null) && (dt.Rows[i]["RuleID"].ToString() != ""))
                    {
                        item.RuleID = int.Parse(dt.Rows[i]["RuleID"].ToString());
                    }
                    if ((dt.Rows[i]["RuleNUmber"] != null) && (dt.Rows[i]["RuleNUmber"].ToString() != ""))
                    {
                        item.RuleNUmber = dt.Rows[i]["RuleNUmber"].ToString();
                    }
                    if ((dt.Rows[i]["RuleNewsType"] != null) && (dt.Rows[i]["RuleNewsType"].ToString() != ""))
                    {
                        item.RuleNewsType = dt.Rows[i]["RuleNewsType"].ToString();
                    }
                    if ((dt.Rows[i]["RuleDesc"] != null) && (dt.Rows[i]["RuleDesc"].ToString() != ""))
                    {
                        item.RuleDesc = dt.Rows[i]["RuleDesc"].ToString();
                    }
                    if ((dt.Rows[i]["RuleContent"] != null) && (dt.Rows[i]["RuleContent"].ToString() != ""))
                    {
                        item.RuleContent = dt.Rows[i]["RuleContent"].ToString();
                    }
                    if ((dt.Rows[i]["RuleUserID"] != null) && (dt.Rows[i]["RuleUserID"].ToString() != ""))
                    {
                        item.RuleUserID = int.Parse(dt.Rows[i]["RuleUserID"].ToString());
                    }
                    if ((dt.Rows[i]["RuleCreateTime"] != null) && (dt.Rows[i]["RuleCreateTime"].ToString() != ""))
                    {
                        item.RuleCreateTime = DateTime.Parse(dt.Rows[i]["RuleCreateTime"].ToString());
                    }
                    list.Add(item);
                }
            }
            return list;
        }

        public bool Delete(int RuleID)
        {
            return this.dal.Delete(RuleID);
        }

        public bool DeleteList(string RuleIDlist)
        {
            return this.dal.DeleteList(RuleIDlist);
        }

        public string ErrorStr()
        {
            return this.dal.ErrorStr();
        }

        public bool Exists(int RuleID)
        {
            return this.dal.Exists(RuleID);
        }

        public DataSet GetAllList()
        {
            return this.GetList("");
        }

        public string GetCardDesc()
        {
            return this.dal.GetCardDesc();
        }

        public DataSet GetList(string strWhere)
        {
            return this.dal.GetList(strWhere);
        }

        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return this.dal.GetList(Top, strWhere, filedOrder);
        }

        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            return this.dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
        }

        public int GetMaxId()
        {
            return this.dal.GetMaxId();
        }

        public Chain.Model.WeiXinRule GetModel(int RuleID)
        {
            return this.dal.GetModel(RuleID);
        }

        public Chain.Model.WeiXinRule GetModelByNewsRuleID(string RuleNUmber)
        {
            return this.dal.GetModelByNewsRuleID(RuleNUmber);
        }

        public List<Chain.Model.WeiXinRule> GetModelList(string strWhere)
        {
            DataSet list = this.dal.GetList(strWhere);
            return this.DataTableToList(list.Tables[0]);
        }

        public int GetRecordCount(string strWhere)
        {
            return this.dal.GetRecordCount(strWhere);
        }

        public string Reply1()
        {
            return this.dal.Reply1();
        }

        public string Reply2()
        {
            return this.dal.Reply2();
        }

        public bool Update(Chain.Model.WeiXinRule model)
        {
            return this.dal.Update(model);
        }
    }
}

